home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
database
/
prg
/
prg.doc
< prev
Wrap
Text File
|
1987-12-13
|
5KB
|
132 lines
Docs for Prg.com - dbase programmer's utility
R. Trevithick, 12/02/87
This is a little utility program for dBase programmers. It
provides two basic services, both geared toward patching up
sloppy program (.prg) files.
Structure Analysis
When invoked with only a filename, it counts up the number of
flow statements which are supposed to occur in pairs. That is,
Do While-Enddo, Do Case-Endcase, If-Endif and Text-Endtext. It
lists the number of occurrences of each of these, and flags any
which are mis-matched. I'm told that this is the most common
mistake made in dBase programs...
Formatting (block indentation and case conversions)
There are three options which can be entered on the command line,
following the filename, which have to do with block indentation.
Indentation simply makes programs easier to read and understand.
For example:
If Read_File
Do While .not. Eof()
statement
statement
statement
Enddo
Endif
It's obvious from this that nothing get's done if Read_File is
false, and it's equally clear which statements will be executed
inside the 'while' loop. Maintaining a program without some
similar kind of format can be a nightmare, especially when it's
hundreds of lines long.
Using the /d (display) option after the filename will cause the
file to be displayed on the screen with this sort of indentation.
Note that you have to be fairly quick with ctrl-s (pause) if you
want to actually have time to look at it.
Using the /w (Write) option will cause the file you specified to
actually be re-written in the indented style. The revised file
will be saved with the original filename, and the original file
will be renamed to filename.old. See the examples below.
Using the /x option (where x is a number from 0-9) will set the
size of the indents to be used. It defaults to 3. Note that
only the first character following the / is used, so a number
like 15 will be read as a 1. I sincerely hope that nobody is in
the habit of indenting more than 9 spaces! Also note that files
displayed to the screen are automatically chopped off at 80
characters so the wrapping doesn't hinder readability. This will
NOT happen in the file you create with the /w option, however-
so don't let it make you nervous.
There are another three options which allow case conversions to be made.
Comments beginning with '*', and anything between a 'TEXT' and an
'ENDTEXT' will be left unchanged.
Using the /u option will convert all characters to Upper case.
The /l option will convert all characters to Lower case, with the
exception of the first character of words. Hence, 'SET' would be
changed to 'Set'.
The /f option will Force all characters to lower case, including the
first characters of words. Hence, 'SET' would become 'set'.
Examples
Let's say we have a file called Test.Prg which we want to work
with. Suggestion: copy one of your existing files to a special
directory, and use it for experimenting.
We could enter the following commands:
prg test
This would simply display a listing of the number of
occurrences of statements such as 'Do while' and 'Enddo' in
your file. Obviously, you have a problem if there are more
Do While's than Enddo's or vice-versa.
prg test /d
This would cause the file to be listed to the screen in the
indented format described above.
prg test /w
This would re-write the 'Test.Prg' file in the indented
format, and save an unmodified version of the original file
under the name 'Test.Old'.
prg test /d /5
This would display the file with blocks indented by 5 spaces
instead of 3.
prg test /w /5 /l
This would format the file (see /w above) with blocks
indented by 5 spaces instead of the default 3. The revised file
would have all characters converted to lower case unless they were
the first character of a word or withing a comment or a text block.
You can, of course, use all options in combination if you want
to.
prg test /d /w /5 /l
This would both display AND re-write the file with 5 space
indenting and lower case conversion.
*NOTE that the command line is parsed from left to right, so if you
enter conflicting options (such as /l for lower case and /u for
upper case) the rightmost one will be honored.
------------Changes as of 12/02/87 revision------------
Added case conversion routines (/l /f /u)